﻿using System;

namespace PortableComputerSystem
{
    // 1. 定义DVD播放接口
    public interface IDVDPlayer
    {
        /// <summary>
        /// 播放DVD功能
        /// </summary>
        void PlayDVD();
    }

    // 2. 定义加密电视接口
    public interface IEncryptedTV
    {
        /// <summary>
        /// 收看加密电视频道
        /// </summary>
        void WatchEncryptedChannel();
    }

    // 3. 定义FM收音机接口
    public interface IFMRadio
    {
        /// <summary>
        /// 接收调频广播
        /// </summary>
        void ReceiveFMRadio();
    }

    // 4. 实现便携式计算机类
    public class PortableComputer : IDVDPlayer, IEncryptedTV, IFMRadio
    {
        // 私有字段
        private string _brand;
        private string _model;
        private bool _isPoweredOn;
        private double _screenSize;

        // 构造函数
        public PortableComputer(string brand, string model, double screenSize)
        {
            _brand = brand;
            _model = model;
            _screenSize = screenSize;
            _isPoweredOn = false;
        }

        // 公共属性
        public string Brand
        {
            get { return _brand; }
            set { _brand = value; }
        }

        public string Model
        {
            get { return _model; }
            set { _model = value; }
        }

        public double ScreenSize
        {
            get { return _screenSize; }
            set { _screenSize = value; }
        }

        public bool IsPoweredOn
        {
            get { return _isPoweredOn; }
        }

        // 电源控制方法
        public void PowerOn()
        {
            _isPoweredOn = true;
            Console.WriteLine($"{_brand} {_model} 已开机");
        }

        public void PowerOff()
        {
            _isPoweredOn = false;
            Console.WriteLine($"{_brand} {_model} 已关机");
        }

        // 实现IDVDPlayer接口
        public void PlayDVD()
        {
            if (!_isPoweredOn)
            {
                Console.WriteLine("请先开机！");
                return;
            }
            Console.WriteLine($"正在播放DVD - {_brand} {_model}");
            Console.WriteLine("DVD播放功能运行中...");
        }

        // 实现IEncryptedTV接口
        public void WatchEncryptedChannel()
        {
            if (!_isPoweredOn)
            {
                Console.WriteLine("请先开机！");
                return;
            }
            Console.WriteLine($"正在收看加密电视频道 - {_brand} {_model}");
            Console.WriteLine("频道解码中...信号稳定");
        }

        // 实现IFMRadio接口
        public void ReceiveFMRadio()
        {
            if (!_isPoweredOn)
            {
                Console.WriteLine("请先开机！");
                return;
            }
            Console.WriteLine($"正在接收调频广播 - {_brand} {_model}");
            Console.WriteLine("FM收音机功能运行中...搜索频道");
        }

        // 显示设备信息
        public void DisplayInfo()
        {
            Console.WriteLine($"\n=== 设备信息 ===");
            Console.WriteLine($"品牌: {_brand}");
            Console.WriteLine($"型号: {_model}");
            Console.WriteLine($"屏幕尺寸: {_screenSize}英寸");
            Console.WriteLine($"电源状态: {(_isPoweredOn ? "已开机" : "已关机")}");
        }
    }

    // 5. 主程序类
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("=== 便携式计算机系统演示 ===\n");

            // 创建便携式计算机对象
            PortableComputer myComputer = new PortableComputer("索尼", "PortaView-100", 15.6);

            // 显示设备信息
            myComputer.DisplayInfo();

            // 测试功能
            Console.WriteLine("\n--- 功能测试 ---");

            // 测试关机状态下的功能
            Console.WriteLine("\n1. 关机状态测试:");
            myComputer.PlayDVD();
            myComputer.WatchEncryptedChannel();
            myComputer.ReceiveFMRadio();

            // 开机后测试功能
            Console.WriteLine("\n2. 开机状态测试:");
            myComputer.PowerOn();

            myComputer.PlayDVD();
            myComputer.WatchEncryptedChannel();
            myComputer.ReceiveFMRadio();

            // 关闭设备
            myComputer.PowerOff();

            Console.WriteLine("\n=== 演示结束 ===");
            Console.WriteLine("按任意键退出...");
            Console.ReadKey();
        }
    }
}